<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- 整体显示布局的css -->
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>temperature/css/temperature.css" />
<!-- 树的显示布局的css -->
<link rel="stylesheet"
	href="<%=basePath%>temperature/css/zTreeStyle.css" type="text/css" />
<link rel="stylesheet"
	href="<%=basePath%>temperature/css/tip-darkgray.css" type="text/css" />
<!-- 时间选择css -->
<link rel="stylesheet" href="<%=basePath%>temperature/css/querytime.css"
	type="text/css" />
<script type="text/javascript"
	src="<%=basePath%>temperature/js/jquery-1.4.4.min.js"></script>

<script type="text/javascript"
	src="<%=basePath%>temperature/js/echarts.js"></script>

<!-- 页面加载的其他重要js -->
<script type="text/javascript"
	src="<%=basePath%>temperature/js/temperJsAll.js"></script>
<!-- 页面自动刷新 -->
<meta http-equiv="refresh" content="600">
<title>container</title>
<script type="text/javascript">
	var path = "<%=basePath%>";
</script>
<script type="text/javascript">
	var data = ${pointData};
	var roomHeatDateJson = ${roomHeatDate};
	var roomHeatAreaSum = ${roomHeatAreaSum};
	function loadResource() {
		//楼栋名字回显
		$("#buildingShow").html(parent.treeNodeName);
		//日期时间回显
		$("#timeShow").html(parent.recordDate);
		//门牌号显示
		data = ${pointData};
		for (var i = 0; i < data.length; i++) {
			$("#house" + i).html(data[i].houseNo);
		}
		//获取温度点24小时的温度
		var metVal = [];
		var metValData = [];
		for (var i = 0; i < data.length; i++) {
			metValData = []
			if(data[i].temp != null){
				for(var j = 0; j < data[i].temp.length; j++){
					if(data[i].temp[j] != null){
						metValData.push(data[i].temp[j]);
					}
				}
				metVal.push(metValData);
			}
		}
		//每个温度点平均温度显示
		var sum = 0;
		var nub = [];
		for (var i = 0; i < metVal.length; i++) {
			for(var j = 0; j < metVal[i].length; j++){
				sum = (sum + metVal[i][j]);
			}
			$("#number" + i).html(""+(sum / metVal[i].length).toPrecision(3) + "℃"+"");
			nub.push((sum / metVal[i].length).toPrecision(3));
			sum = 0;
		}
		var mean = 0;
		for (var i = 0; i < nub.length; i++) {
			mean = mean + (nub[i] * 100);
		}
		if(nub.length != 0 ){
			$("#MeanFont").html((mean / 100 / nub.length).toPrecision(3) + "℃");//楼栋平均温度
			$("#MaxFont").html(Math.max.apply(null, nub).toPrecision(3) + "℃");//楼栋最高温度
			$("#MinFont").html(Math.min.apply(null, nub).toPrecision(3) + "℃");//楼栋最低温度
		}else{
			$("#MeanFont").html("0.0" + "℃");//楼栋平均温度
			$("#MaxFont").html("0.0" + "℃");//楼栋平均温度
			$("#MinFont").html("0.0" + "℃");//楼栋平均温度
		}
		for(var i = 0; i < roomHeatDateJson.length; i++){
			roomHeat(1,0);
			if(roomHeatDateJson.length > 1){
				roomHeat(2,1);
			}
		}
	}
	function roomHeat(sum,len){
		if(roomHeatDateJson[len].sumHeatUnit == 1){
			var MWh = roomHeatDateJson[len].sumHeat * 1000;
			$("#squareMeters"+sum).html((MWh / roomHeatAreaSum).toPrecision(3) + "MWh");
		}else if(roomHeatDateJson[len].sumHeatUnit == 2){
			var KWh = roomHeatDateJson[len].sumHeat;
			$("#squareMeters"+sum).html((KWh / roomHeatAreaSum).toPrecision(3) + "KWh");
		}else if(roomHeatDateJson[len].sumHeatUnit == 3){
			var Gj = roomHeatDateJson[len].sumHeat * 277.8;
			$("#squareMeters"+sum).html((Gj / roomHeatAreaSum).toPrecision(3) + "Gj");
		}
	}
	// 获取当前实时室外温度
	$.getScript("http://php.weather.sina.com.cn/js.php?" + $.param({
		city : "北京",
		day : 0,
		password : "DJOYnieT8234jlsK"
	}), function(json) {
		// 	alert(savedate_weather+"__"+status1+"__"+status2+"__"+direction1+"__"+savedate_life);
		/* 返回的数据
		city='北京';year1='14';//month1='02';day1='21';year2='14';month2='02';day2='22';city='北京';
		savedate_weather='2014-02-21';savedate_life='2014-02-21';savedate_zhishu='2014-02-21';
		status1='霾';status2='雾'; figure1='mai';figure2='wu';direction1='无持续风向'; direction2='无持续风向';
		power1='≤3';power2='≤3';temperature1='3';//白天温度temperature2='-2';//晚上温度  */
		$("#OutdoorFont").html(temperature1 + "℃");//室外实时温度
	});
</script>

</head>
<body onmousedown="hidetip()" oncontextmenu="return false;" style="width: 930px; height: 755px; margin: 0px" onload="loadResource()">
	<!-- 折线提示框 -->
	<div id="main" style="opacity: 0.888; background: #ffffff; width: 350px; height: 250px; display: none; position: absolute; z-index: 2; border: 2px solid #617775;"></div>
	<!-- left -->
	<div id="container">
		<div class="content_all" align="center" style="position: relative;">
			<!-- 顶部单元号显示 -->
			<div class="heading" align="center">
				<div id="unitShow" title="单元显示" style="z-index: 1"></div>
				<div id="buildingShow" title="小区楼栋显示" style="z-index: 1"></div>
				<div id="timeShow" title="时间显示" style="z-index: 1"></div>
			</div>
			<div class="user-top" align="center">
				<div id="window-2" onclick="showtip(event,2)">
					<div id="number2" title="温度显示">
						<font color="red" size="4">&nbsp;</font>
					</div>
					<div id="house2" title="门牌号显示">&nbsp;</div>
				</div>
				<div id="window-5" onclick="showtip(event,5)">
					<div id="number5">&nbsp;</div>
					<div id="house5">&nbsp;</div>
				</div>
				<div id="window-8" onclick="showtip(event,8)">
					<div id="number8">&nbsp;</div>
					<div id="house8">&nbsp;</div>
				</div>
			</div>
			<!-- 中间条样式 -->
			<div id="middle-1"><font>&nbsp;</font></div>
			<!-- 中层用户温度点显示 -->
			<div class="user-centre" align="center">
				<div id="window-1" onclick="showtip(event,1)">
					<div id="number1">&nbsp;</div>
					<div id="house1">&nbsp;</div>
				</div>
				<div id="window-4" onclick="showtip(event,4)">
					<div id="number4">&nbsp;</div>
					<div id="house4">&nbsp;</div>
				</div>
				<div id="window-7" onclick="showtip(event,7)">
					<div id="number7">&nbsp;</div>
					<div id="house7">&nbsp;</div>
				</div>
			</div>
			<!-- 中间条样式 -->
			<div id="middle-2"><font>&nbsp;</font></div>
			<!-- 底层用户温度点显示 -->
			<div class="user-bottom" align="center">
				<div id="window-0" onclick="showtip(event,0)">
					<div id="number0">&nbsp;</div>
					<div id="house0">&nbsp;</div>
				</div>
				<div id="window-3" onclick="showtip(event,3)">
					<div id="number3">&nbsp;</div>
					<div id="house3">&nbsp;</div>
				</div>
				<div id="window-6" onclick="showtip(event,6)">
					<div id="number6">&nbsp;</div>
					<div id="house6">&nbsp;</div>
				</div>
			</div>
			<!-- 底层黄条样式 -->
			<div class="page-all" align="center">
				<div id="yellow"></div>
				<!-- 					<div id="next" title="下一页"> -->
				<%-- 						<a id="anext" href="<%=basePath%>temperature/jsp/temperature.jsp"> --%>
				<!-- 							<font id="nexts"> 下一页 </font> -->
				<!-- 						</a> -->
				<!-- 					</div> -->
				<!-- 					<div id="back" title="上一页"> -->
				<%-- 						<a id="aback" href="<%=basePath%>temperature/jsp/temperature.jsp"> --%>
				<!-- 							<font id="backs"> 上一页 </font> -->
				<!-- 						</a> -->
				<!-- 					</div> -->
			</div>
		</div>
		<!-- 底层热表图片 -->
		<div class="table">
			<div id="table-No1"></div>
			<div id="table-No2"></div>
		</div>
		<div id="thisDiv" class="thisdiv" style="border-style: double;">
			<p id="sharp_one"></p>
			<div style="text-align: center; margin-top: -5px;">
				热量表号：${tempMeterList[0].meterNo}
			</div>
			<table border="0" cellspacing="1" cellpadding="3">
				<tr>
					<td style="border: 1px solid #FFFFFF;">供水温度</td>
					<td style="border: 1px solid #FFFFFF;">回水温度</td>
					<td style="border: 1px solid #FFFFFF;">供回水温差</td>
					<td style="border: 1px solid #FFFFFF;">累计流量</td>
					<td style="border: 1px solid #FFFFFF;">累计热量</td>
				</tr>
				<tr>
					<td style="border: 1px solid #FFFFFF;"><s:property
							value="formatDouble(tempMeterList[0].supplyTemperature)" />&#8451;</td>
					<td style="border: 1px solid #FFFFFF;"><s:property
							value="formatDouble(tempMeterList[0].backTemperature)" />&#8451;</td>
					<td style="border: 1px solid #FFFFFF;"><s:property
							value="formatDouble(tempMeterList[0].temperatureDiff)" />&#8451;</td>
					<td style="border: 1px solid #FFFFFF;">
						<s:property value="formatDouble(tempMeterList[0].sumFlow)" />
						<s:if test="tempMeterList[0].sumFlowUnit==1">m&sup3;</s:if>
		          		<s:if test="tempMeterList[0].sumFlowUnit==2">dm&sup3;</s:if>
		          		<s:if test="tempMeterList[0].sumFlowUnit==3">cm&sup3;</s:if>
					</td>
					<td style="border: 1px solid #FFFFFF;">
						<s:property value="formatDouble(tempMeterList[0].sumHeat)" />
						<s:if test="tempMeterList[0].sumHeatUnit==1">MWh</s:if>
		          		<s:if test="tempMeterList[0].sumHeatUnit==2">kWh</s:if>
		          		<s:if test="tempMeterList[0].sumHeatUnit==3">Gj</s:if>		
					</td>
				</tr>
				<tr>
					<td style="border: 1px solid #FFFFFF;">瞬时功率</td>
					<td style="border: 1px solid #FFFFFF;">热功率</td>
					<td style="border: 1px solid #FFFFFF;">瞬时流量</td>
					<td style="border: 1px solid #FFFFFF;">楼栋面积</td>
					<td style="border: 1px solid #FFFFFF;">每平米热量</td>
				</tr>
				<tr>
					<td style="border: 1px solid #FFFFFF;">
						<s:property value="formatDouble(tempMeterList[0].instantPower)" />
						<s:if test="tempMeterList[0].heatPowerUnit==1">MW</s:if>
		          		<s:if test="tempMeterList[0].heatPowerUnit==2">kW</s:if>
		          		<s:if test="tempMeterList[0].heatPowerUnit==3">Gj/h</s:if>
					</td>
					<td style="border: 1px solid #FFFFFF;">
						<s:property value="formatDouble(tempMeterList[0].heatPower)" />
						<s:if test="tempMeterList[0].heatPowerUnit==1">MW</s:if>
		          		<s:if test="tempMeterList[0].heatPowerUnit==2">kW</s:if>
		          		<s:if test="tempMeterList[0].heatPowerUnit==3">Gj/h</s:if>
					</td>
					<td style="border: 1px solid #FFFFFF;">
						<s:property value="formatDouble(tempMeterList[0].instantFlow)" />
						<s:if test="tempMeterList[0].sumFlowUnit==1">m&sup3;/h</s:if>
		          		<s:if test="tempMeterList[0].sumFlowUnit==2">dm&sup3;/h</s:if>
		          		<s:if test="tempMeterList[0].sumFlowUnit==3">cm&sup3;/h</s:if>
					</td>
					<td style="border: 1px solid #FFFFFF;">
						<s:property value="formatDouble(roomHeatAreaSum)" />
						m³
					</td>
					<td id="squareMeters1" style="border: 1px solid #FFFFFF;"></td>
				</tr>
			</table>
		</div>
		<s:if test="tempMeterList.size>1">
			<div id="thisTable" class="thistable" style="border-style: double;">
				<p id="sharp_two"></p>
				<div style="text-align: center; margin-top: -5px;">
					热量表号：${tempMeterList[1].meterNo}
				</div>
				<table border="0" cellspacing="1" cellpadding="3">
					<tr>
						<td style="border: 1px solid #FFFFFF;">供水温度</td>
						<td style="border: 1px solid #FFFFFF;">回水温度</td>
						<td style="border: 1px solid #FFFFFF;">供回水温差</td>
						<td style="border: 1px solid #FFFFFF;">累计流量</td>
						<td style="border: 1px solid #FFFFFF;">累计热量</td>
					</tr>
					<tr>
							<td style="border: 1px solid #FFFFFF;"><s:property
									value="formatDouble(tempMeterList[1].supplyTemperature)" />&#8451;</td>
							<td style="border: 1px solid #FFFFFF;"><s:property
									value="formatDouble(tempMeterList[1].backTemperature)" />&#8451;</td>
							<td style="border: 1px solid #FFFFFF;"><s:property
									value="formatDouble(tempMeterList[1].temperatureDiff)" />&#8451;</td>
							<td style="border: 1px solid #FFFFFF;">
								<s:property value="formatDouble(tempMeterList[1].sumFlow)" />
								<s:if test="tempMeterList[1].sumFlowUnit==1">m&sup3;</s:if>
				          		<s:if test="tempMeterList[1].sumFlowUnit==2">dm&sup3;</s:if>
				          		<s:if test="tempMeterList[1].sumFlowUnit==3">cm&sup3;</s:if>
							</td>
							<td style="border: 1px solid #FFFFFF;">
								<s:property value="formatDouble(tempMeterList[1].sumHeat)" />
								<s:if test="tempMeterList[1].sumHeatUnit==1">MWh</s:if>
				          		<s:if test="tempMeterList[1].sumHeatUnit==2">kWh</s:if>
				          		<s:if test="tempMeterList[1].sumHeatUnit==3">Gj</s:if>
							</td>
					</tr>
					<tr>
						<td style="border: 1px solid #FFFFFF;">瞬时功率</td>
						<td style="border: 1px solid #FFFFFF;">热功率</td>
						<td style="border: 1px solid #FFFFFF;">瞬时流量</td>
						<td style="border: 1px solid #FFFFFF;">楼栋面积</td>
						<td style="border: 1px solid #FFFFFF;">每平米热量</td>
					</tr>
					<tr>
							<td style="border: 1px solid #FFFFFF;">
								<s:property value="formatDouble(tempMeterList[1].instantPower)" />
								<s:if test="tempMeterList[1].heatPowerUnit==1">MW</s:if>
				          		<s:if test="tempMeterList[1].heatPowerUnit==2">kW</s:if>
				          		<s:if test="tempMeterList[1].heatPowerUnit==3">Gj/h</s:if>
							</td>
							<td style="border: 1px solid #FFFFFF;">
								<s:property value="formatDouble(tempMeterList[1].heatPower)" />
								<s:if test="tempMeterList[1].heatPowerUnit==1">MW</s:if>
				          		<s:if test="tempMeterList[1].heatPowerUnit==2">kW</s:if>
				          		<s:if test="tempMeterList[1].heatPowerUnit==3">Gj/h</s:if>
							</td>
							<td style="border: 1px solid #FFFFFF;">
								<s:property value="formatDouble(tempMeterList[1].instantFlow)" />
								<s:if test="tempMeterList[1].sumFlowUnit==1">m&sup3;/h</s:if>
				          		<s:if test="tempMeterList[1].sumFlowUnit==2">dm&sup3;/h</s:if>
				          		<s:if test="tempMeterList[1].sumFlowUnit==3">cm&sup3;/h</s:if>
							</td>
							<td style="border: 1px solid #FFFFFF;">
								<s:property value="formatDouble(roomHeatAreaSum)" />
								m³
							</td>
							<td id="squareMeters2" style="border: 1px solid #FFFFFF;"></td>
					</tr>
				</table>
			</div>	
			</s:if>
	</div>
	<!-- container -->
	<!-- 右侧楼栋平均数据显示 -->
	<div id="tempValue" align="center">
		<p id="sharp_stree" style="z-index: 1"></p>
		<div id="tempFont">
			<div id="temoFont_value">
				<font>楼栋平均温度：</font> <font size="4" color="#00FF01" id="MeanFont">0.00℃</font>
			</div>
			<div id="temoFont_value">
				<font>楼栋最高温度：</font> <font size="4" color="#00FF01" id="MaxFont">0.00℃</font>
			</div>
			<div id="temoFont_value">
				<font>楼栋最低温度：</font> <font size="4" color="#00FF01" id="MinFont">0.00℃</font>
			</div>
			<div id="temoFont_value">
				<font>室外实时温度：</font> <font size="4" color="#00FF01" id="OutdoorFont">0.00℃</font>
			</div>
			<!-- 				<div id="temoFont_value"></div> -->
		</div>
	</div>
</body>

<!-- 提示框js格式 -->
<script type="text/javascript"
	src="<%=basePath%>temperature/js/myEcharts.js"></script>
</html>